var urlParams = new URLSearchParams(location.search),
	class_id = urlParams.get("class_id"),
	uid = $.cookie("uid"),
	tid = urlParams.get("tid"),
	id = 0,
	url = "",
	limit = $("#ygl_xl").val(),
	setTotalCount = 0,
	count = 0;
if (class_id != null) {
	url = "/product/classification";
	id = class_id;
} else if (tid != null) {
	url = "/product/lookup_team";
	id = tid;
} else {
	id = "";
	url = "/product/list"

}
$.ajax({
	type: "get",
	url: url,
	dataType: "JSON",
	async: false,
	data: {
		id: id,
		page: 1,
		limit: 20
	},
	success: function (data) {
		count = data.count;
		var str = ""
		for (var key in data.data) {
			str += template("tpl_ygl_procuct", data.data[key])
		}
		$("#ygl_pruduct").empty().append(str)
	}
})



var page_num;
page_num = count / limit;
if (page_num < 1)
	page_num = 1;
else
	page_num = Math.ceil(page_num)
/**********分页器*********/
$('#box').paging({
	initPageNo: 1, // 初始页码
	totalPages: page_num, //总页数
	totalCount: '共' + count + '件商品', // 条目总数
	slideSpeed: 600, // 缓动速度。单位毫秒
	jump: true, //是否支持跳转
	callback: function (page) { // 回调函数
		$.ajax({
			type: "get",
			url: url,
			dataType: "JSON",
			data: {
				id: id,
				page: page,
				limit: limit
			},
			success: function (data) {
				count = data.count;
				var str = ""
				for (var key in data.data) {
					str += template("tpl_ygl_procuct", data.data[key])
				}
				$("#ygl_pruduct").empty().append(str)
				$("body,html").animate({scrollTop:0},300)
				return false;
			}
		})
	}
})
